package com.glodon.paas.document.dao.mysql;

import org.springframework.beans.factory.annotation.Autowired;

import com.glodon.paas.document.dao.MultiPartUploadHandleDao;
import com.glodon.paas.document.dao.domain.MultiPartUploadHandleEntity;
import com.glodon.paas.document.dao.mapper.MultiPartUploadHandleEntityMapper;

public class MultiPartUploadHandleDaoMysqlImpl implements MultiPartUploadHandleDao {

    @Autowired
    private MultiPartUploadHandleEntityMapper multiPartUploadHandleEntityMapper;

    @Override
    public String insert(MultiPartUploadHandleEntity entity) {
        assert entity.getRevisionId() != null : "MultiPartUploadHandleEntity.getRevisionId() is null";
        multiPartUploadHandleEntityMapper.insertSelective(entity);
        return entity.getRevisionId();
    }

    @Override
    public MultiPartUploadHandleEntity get(String revisionId) {
        return multiPartUploadHandleEntityMapper.selectByPrimaryKey(revisionId);
    }

    @Override
    public int delete(String revisionId) {
        return multiPartUploadHandleEntityMapper.deleteByPrimaryKey(revisionId);
    }

    @Override
    public MultiPartUploadHandleEntity getHandlerByRevision(String revisionId) {
        return multiPartUploadHandleEntityMapper.selectByPrimaryKey(revisionId);
    }

}
